<?php
	$ls_gridname	= 'list_g13';


// ----------------- >> Form Detail << ----------------- ?>

<script>
	console.clear();
	var f_status = function(val) {
        return (val == '1' ? '<img src="' + gs_path + '/content/images/ico_success.png" title="Sudah Dibayar" />' : '<img src="' + gs_path + '/content/images/delete.png" title="Belum Dibayar" />');
    };

    function reloadListThr(p) {
    	console.log(p);
		$('#<?php echo $ls_gridname; ?>').datagrid({
			queryParams: {
				idPeriode: p
			}
		});
    }

	$(function(){
		var lastIndex;
		$('#<?php echo $ls_gridname; ?>').datagrid({
			url:gs_path+'/'+controller+'/getdata/',
			queryParams: {
				// idPeriode: 0
				idPeriode: $('#id_periode_thr_fk').val()
			},
			width:800,
			height:500,
			fitColumns:true,
			toolbar:[
				{
					text:'Print',
					iconCls:'icon-print',
					handler:function(){
						window.open(gs_path+'/'+controller+'/cetak?id_periode_thr_fk='+$('#id_periode_thr_fk').val(), 'myWin', 'height=500,width=700,status=yes,toolbar=no,menubar=yes,location=no,scrollbars=yes');
						// $.messager.alert('Info','Fitur print segera menyusul di update berikutnya','info');
					}
				},'-',{
					text:'Detail Gaji 13',
					iconCls:'icon-edit',
					handler:function(){
						var oSel=$('#<?php echo $ls_gridname; ?>').datagrid('getSelected'); 
						if(oSel==null){ 
							alert('Please select row!'); 
						} else{ 
							var $popup = openPopup({ title: '&nbsp;', 
                                width: 600,
                                height: 350,
                                url: gs_path + '/' + controller + '/form_detail_gaji/'+oSel.id_g13_pk+'/'+oSel.nama_karyawan
                            });
						}
					}
				}
			]
		});
	});
</script>


<table id="<?php echo $ls_gridname; ?>" style="width:700px;height:auto" iconCls="icon-edit" singleSelect="true" idField="itemid">
	<thead>
		<tr>
			<th field="id_g13_pk" width="100" >ID</th>
	        <th field="nama_karyawan" width="150" >Karyawan</th>
			<th field="nama_periode_thr" width="120" >Periode</th>
	        <!-- <th field="total" width="100" formatter="formatNumeric" >Total Gaji</th> -->
	        <th field="jml_penambah" width="100" formatter="formatNumeric" align="right">Pendapatan</th>
	        <th field="jml_pengurang" width="100" formatter="formatNumeric" align="right">Potongan</th>
	        <th field="jml_terima" width="100" formatter="formatNumeric" align="right">Yang Diterima</th>
	        <th field="status_pembayaran" width="40" align="center" formatter="f_status" >Status</th>
		</tr>
	</thead>
</table>